﻿#include "../head/SavingsAccount.hh"
#include "../head/CheckingAccount.hh"
#include "../head/tools.hh"
#include <iostream>

SavingsAccount::SavingsAccount(std::string id, long long  init_balance, std::string holder) : Account(id, init_balance, holder) {}

void SavingsAccount::showinfo() {
    std::cout << "===== Bank Account: " << accountId << " (savings Account) =====\n";
    std::cout << "Account holder: " << accountHolder << std::endl;
    std::cout << "Balance: ￥" << tools::amountdisplay(balance) << "\n";
}

std::string SavingsAccount::generateAccountID()
{
    std::string accountId;
    // 账户类型：21 - 储蓄账户，22 - 支票账户
    accountId += "6221";
    // 生成四位分支代码
    accountId += "-" + tools::generateRandomNumber(4);
    // 生成八位账户号（分成两部分：ZZZZ-AAAA）
    accountId += "-" + tools::generateRandomNumber(4) + "-" + tools::generateRandomNumber(4);
    return accountId;
}
